<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./static/axios.min.js"></script>
    <script src="./static/vue.min.js"></script>
    <!-- 本地引入lib-master -->
    <link rel="stylesheet" type="text/css" href="lib-master/theme-chalk/index.css" />
    <script src="lib-master/index.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="app">
    <template>
    <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
                    <el-form-item label="拼团活动表id" prop="tourDivGoodsId">
      <el-input v-model="dataForm.tourDivGoodsId" placeholder="拼团活动表id"></el-input>
    </el-form-item>
                <el-form-item label="拼团商品id" prop="goodsId">
      <el-input v-model="dataForm.goodsId" placeholder="拼团商品id"></el-input>
    </el-form-item>
                <el-form-item label="拼团订单表id" prop="tourDivOrderId">
      <el-input v-model="dataForm.tourDivOrderId" placeholder="拼团订单表id"></el-input>
    </el-form-item>
                <el-form-item label="参团用户id" prop="userId">
      <el-input v-model="dataForm.userId" placeholder="参团用户id"></el-input>
    </el-form-item>
                <el-form-item label="参团人昵称" prop="nickname">
      <el-input v-model="dataForm.nickname" placeholder="参团人昵称"></el-input>
    </el-form-item>
                <el-form-item label="参团状态(0.参团,1.过期(超过拼团时间))" prop="tourDivJoinStatus">
      <el-input v-model="dataForm.tourDivJoinStatus" placeholder="参团状态(0.参团,1.过期(超过拼团时间))"></el-input>
    </el-form-item>
                <el-form-item label="创建时间" prop="createTime">
      <el-input v-model="dataForm.createTime" placeholder="创建时间"></el-input>
    </el-form-item>
                <el-form-item label="参团时间" prop="joinTime">
      <el-input v-model="dataForm.joinTime" placeholder="参团时间"></el-input>
    </el-form-item>
                <el-form-item label="拼团价格" prop="tourDivPrice">
      <el-input v-model="dataForm.tourDivPrice" placeholder="拼团价格"></el-input>
    </el-form-item>
            </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
    </el-dialog>
    </template>
</div>
</body>
<script>
    new Vue({
        el: "#app",
    data () {
      return {
        visible: false,
        dataForm: {
          id: 0,
          tourDivGoodsId: '',
          goodsId: '',
          tourDivOrderId: '',
          userId: '',
          nickname: '',
          tourDivJoinStatus: '',
          createTime: '',
          joinTime: '',
          tourDivPrice: ''
        },
        dataRule: {
          tourDivGoodsId: [
            { required: true, message: '拼团活动表id不能为空', trigger: 'blur' }
          ],
          goodsId: [
            { required: true, message: '拼团商品id不能为空', trigger: 'blur' }
          ],
          tourDivOrderId: [
            { required: true, message: '拼团订单表id不能为空', trigger: 'blur' }
          ],
          userId: [
            { required: true, message: '参团用户id不能为空', trigger: 'blur' }
          ],
          nickname: [
            { required: true, message: '参团人昵称不能为空', trigger: 'blur' }
          ],
          tourDivJoinStatus: [
            { required: true, message: '参团状态(0.参团,1.过期(超过拼团时间))不能为空', trigger: 'blur' }
          ],
          createTime: [
            { required: true, message: '创建时间不能为空', trigger: 'blur' }
          ],
          joinTime: [
            { required: true, message: '参团时间不能为空', trigger: 'blur' }
          ],
          tourDivPrice: [
            { required: true, message: '拼团价格不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            if (this.dataForm.id == "") {
                axios.post("http://localhost:7000/tourdiv/tourdivrecord/save", this.dataForm).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.getDataList();
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
            }else {
                axios.post("http://localhost:7000/tourdiv/tourdivrecord/update", this.dataForm).then(
                        ({
                             data
                         }) => {
                            if (data && data.code === 0) {
                                this.$message({
                                    message: '操作成功',
                                    type: 'success',
                                    duration: 1500,
                                    onClose: () => {
                                        this.visible = false
                                        this.getDataList();
                                    }
                                })
                            } else {
                                this.$message.error(data.msg)
                            }
                        })
            }
          }
        })
      }
    }
  })
</script>
</html>
